package ubiqweb.spring3.dao;

import java.util.List;

import ubiqweb.spring3.model.Payment;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("paymentDao")
public class PaymentDaoImpl implements PaymentDao {

	@Autowired
	private SessionFactory sessionFactory;
	
	@SuppressWarnings("unchecked")
	public List<Payment> listPayments() {		
		return (List<Payment>) sessionFactory.getCurrentSession().createCriteria(Payment.class).list();
	}
	
	@SuppressWarnings("unchecked")
	public List<Payment> listPayments(String userId) {		
		return (List<Payment>) sessionFactory.getCurrentSession().createQuery("from Payment where userId = '" + userId + "'").list();
	}
}